<?

require_once  $_SERVER['DOCUMENT_ROOT']."/../_lib/base/common.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.template.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.holidays.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.photos.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.hotels.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.airports.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.destinations.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.exchange_rates.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.holiday_special_offers.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.lurls.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.tree.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.reviews.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.holiday_top_deals.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.holiday_filters.php";

	$template = new template();
	$template->section_highlight = "holidays";
	$template->left_col = true;
	$template->search_tab = "holidays";
	$template->title = "Cheap holidays from Ireland, Book Online";
	$template->meta_description = "Book cheap holidays from Ireland to Lanzarote, Majorca, Portugal and more. Get last minute deals and save!";
	
	$template->ld_head();
	
	$lurls = new lurls();
	$holidays = new holidays();
	$destinations = new destinations();
	$hotels = new hotels();
	$airports = new airports();
	$photos = new photos();
	$tree = new tree();
	
?>





<div class="box_title_h2">
<div class="box_title_h2_wm box_title_h2_wm_1">

	<h2>Holiday Deals</h2>
	<p>Cheap package holidays from Ireland to all the top holiday destinations in Europe</p>
    
</div>
</div>






<!-- Start left column -->


<div class="col_290 margin_right_20">









	
	
	
<?
$specials = new holiday_special_offers();
$params['order'] = "random";
$params['limit'] = "7";
$current_specials = $specials->get_specials($params);
shuffle($current_specials);
unset($params);
if(!empty($current_specials)){
$holiday_references = new holiday_references();
$holiday_filters = new holiday_filters();
?>



<!-- Start special offers -->



<div class="box_title_h3_bg">
<div class="box_title_h3_left">
<div class="box_title_h3_wm box_title_h3_wm_1">
<h3 class="box_title_h3" title="Cheap Holiday Deals">Holiday Deals</h3>
</div>
</div>
</div>


<?


foreach($current_specials as $special_values){

	// Holiday filter
	$filter_out = false;
	$params['holiday_reference_id'] = $special_values['reference_id'];
	if($holiday_filters->find_filtered_holiday($params)){
		$filter_out = true;
	}
	unset($params);
	
	// Get Holiday values
	$holiday_values = $holiday_references->build_holiday_keys(explode('~',$special_values['string']));

	
	// Filter by date
	if($holiday_values['departure_date']<=date('ymd')){
		$filter_out = true;
	}
	
if(!$filter_out){


	// Get hotel 
	$params['tree_id'] = $special_values['hotel_tree_id'];
	$params['cache']['seconds'] = '2400';
	$lookup = $hotels->lookup_hotel($params);
	unset($params);
	
	// Set values
	$hotel_values = $lookup['hotel_values'];
	$resort_values = $lookup['resort_values'];
	$destination_values = $lookup['destination_values'];


	// get photo url
	$lead_hotel_thumb_url = $tree->photo_url($hotel_values['main_photo']);
	
	// Departure airport lookup
	$params['airport_code'] = $holiday_values['departure_airport'];
	$params['cache']['seconds'] = '2400';
	$departure_airport_values = $airports->get_airport($params);
	unset($params);
	


	// Get the adult display price
	$display_price = floor($holiday_values['price_adult']);

	
	// Get LURL
	$params['reference_id'] = $special_values['reference_id'];
	$params['tree_id'] = $special_values['hotel_tree_id'];
	$offer_lurl = $lurls->get_holiday_lurl($params);
	unset($params);
	
	// Link titles
	$link_title = "Special offer holiday to ".$destination_values['name'];
	
	
?>


<!-- Start offer instance -->
<div class="lowlight offer_body_div" onclick="location='<?= $offer_lurl ?>'" onmouseover="this.className='highlight offer_body_div';" onmouseout="this.className='lowlight offer_body_div';">

<div class="col_80 margin_right_10">
    <div class='thumb_cover_div'>
    <a href="<?= $offer_lurl ?>" title="<?= $link_title ?>">
    <img src='<?= $lead_hotel_thumb_url ?>' alt='<?= $hotel_values['name'] ?>' class="thumb_image_80" />
    <img src="/images/thumb_cover_80_59.gif" class="thumb_cover" alt='<?= $hotel_values['name'] ?>'  />
    </a>
    </div>
</div>



<div class="col_190">

<p class="title_big"><a href="<?= $offer_lurl ?>" title="<?= $link_title ?>"><?= $destination_values['name'] ?></a></p>
<p class="title_med"><a href="<?= $offer_lurl ?>" title="<?= $link_title ?>"><?= $hotel_values['name'] ?></a></p>
<p class="title_text"><?= $holiday_values['nights'] ?> nights, from <?= $departure_airport_values[0]['simple'] ?>, <a class="price_med" href="<?= $offer_lurl ?>" title="<?= $link_title ?>">&euro;<?= $display_price ?></a></p>

</div>


<div class="clearing"></div>



</div>
<!-- End offer instance -->


<?

unset($current_specials, $hotel_values,$resort_values,$destination_values,$departure_airport_values, $offer_lurl,$display_price);

}

}


?>
<div style="margin-bottom: 10px"></div>


<ul class="list_qlinks">
	<li><a href="/holidays/special_offers.html">View all Special Offers</a></li>
</ul>

<!-- End special offers -->


<? } ?>






















<?
	// Display a random destination
	$random_destination = $destinations->get_random_destination();
	$random_destination = $random_destination[0];
	// Get LURL
	$destination_lurl = $lurls->get_branch_lurl($random_destination['tree_id']);
	unset($params);
	
	include SITE_ROOT_PATH."/_lib/html/highlight_destination.php";

?>





	
	
	


	

</div>
<!-- End left column -->





























<!-- Start right column -->

<div class="col_300">







<!-- Start last minute holidays -->

<div class="box_title_h3_bg">
<div class="box_title_h3_left">
<div class="box_title_h3_wm box_title_h3_wm_4">
<h3 class="box_title_h3" title="Last Minute Holidays">Last Minute Holidays</h3>
</div>
</div>
</div>

<?

$holiday_top_deals = new holiday_top_deals();
$params['limit'] = '8';
$params['cache']['seconds'] = '600';
$holiday_top_deals_values = $holiday_top_deals->get_top_deals($params);
unset($params);
if(!empty($holiday_top_deals_values)){

$item_url = "";
$item_title = "";

?>

<ul class="list_last_min">
<?

	foreach($holiday_top_deals_values as $values_top_deals){
	

		// Get destination using airport code and name synonyms as paramaters
		$params['airport_code'] = $values_top_deals['destination_airport'];
		$params['type_id'] = '1';
		$params['position'] = 'bottom';
		$params['cache']['seconds'] = '2400';
		$destination_values = $destinations->destination_lookup($params);
		$destination_values = $destination_values[0];
		unset($params);
		
		// Get departure airport
		$params['airport_code'] = $values_top_deals['departure_airport'];
		$params['cache']['seconds'] = '2400';
		$item_departure_airport = $airports->get_airport($params);
		unset($params);
		
		$url_string = $lurls->holiday_list_lurl($values_top_deals);
	
?>

	<li><strong><?= $destination_values['name'] ?></strong>, <?= display_sabs_date($values_top_deals['departure_date'],'jS M') ?>, <?= $values_top_deals['nights'] ?>nts,  from <?= $item_departure_airport[0]['simple'] ?> <a class="price_med" href="<?= $url_string ?>">&euro;<?= $values_top_deals['price']; ?></a></li>
    
<?

}

?>	
	
</ul>


<ul class="list_qlinks">
  <li title="last minute holidays"><a href="/holidays/last_minute.html" title="last minute holidays">More last minute holidays</a></li>
</ul>


<?

}

?>


<!-- End last minute holidays -->


















<? 

$handle = fopen(FILE_TOP_SEARCHES, "r");
$top_destinations_file_contents = fread($handle, filesize(FILE_TOP_SEARCHES));
fclose($handle);

$top_destinations = explode(',', $top_destinations_file_contents);

if(!empty($top_destinations)){
?>


<!-- Start top destinaitons -->

<div class="box_lb_brd_300">
<div class="box_lb_brd_300_cap">
<div class="box_lb_brd_300_shoe">
<div class="box_lb_brd_bg_hat">

<div class="box_padding">

<h4 title="Top Holiday Destinations">Top Holiday Destinations</h4>
<p>Top holiday destinations this week:</p>
<ul>
<?
$destinations_id_array = array();
$i=0;
foreach($top_destinations as $destination_airport_code){


	$params['airport_code'] = $destination_airport_code;
	$params['type_id'] = '1';
	$params['position'] = 'bottom';
	$params['cache']['seconds'] = '2400';
	$destination_values = $destinations->destination_lookup($params);
	$destination_values = $destination_values[0];
	unset($params);
	
	$destination_lurl = $lurls->get_branch_lurl($destination_values['tree_id']);

	
	if($destination_values AND (!in_array($destination_values['tree_id'], $destinations_id_array))){

		echo "<li title='".$destination_values['name']." holidays'><a href='".$destination_lurl."' title='".$destination_values['name']."'>".$destination_values['name']."</a></li>";
		
		$i++;
		
	}

	$destinations_id_array[] = $destination_values['tree_id'];
	
	if($i>9) break;
	
} 

?>
</ul>

</div>

</div>
</div>
</div>
</div>


<br />


<!-- End top destinations -->
<? } ?>







<?

	$reviews = new reviews();
	$params['limit'] = '2';
	$params['status'] = 'a';
	$latest_reviews = $reviews->get_reviews($params);

?>



<!-- Start latest customer reviews -->


<div class="box_title_h3_bg">
<div class="box_title_h3_left">
<div class="box_title_h3_wm box_title_h3_wm_2">
<h3 class="box_title_h3" title="Latest Customer Reviews">Latest Customer Reviews</h3>
</div>
</div>
</div>

<p class="no_margin">Get the inside scope on our hotels directly from the customer.</p>


<?

foreach($latest_reviews as $review_values){

	// Get hotel 
	$params['tree_id'] = $review_values['tree_id'];
	$hotel_values = $tree->get_branch($params);
	$hotel_values = $hotel_values[0];
	unset($params);
	
	// Get LURL
	$review_lurl = $lurls->get_hotel_review_lurl($hotel_values['tree_id']);

?>


<!-- Start customer review -->

<div class="box_lb_rev_300_cap">

<p style="margin:0; padding: 20px 10px 2px 10px"><strong><?= $review_values['reviewer_name'] ?></strong> gave a the <strong><?= $hotel_values['name'] ?></strong> rating of <?= output_rating($review_values['overall'], "rate", true); ?> and said...</p>

</div>

<div class="box_lb_rev_300">
<div class="box_lb_rev_300_cap2">
<div class="box_lb_rev_300_shoe">

<div class="box_padding">

<p class="title_med" title="<?= $hotel_values['name']." ".$review_values['review_title'] ?>"><?= $review_values['review_title'] ?></p>

<p class="no_margin"><?= trim_me($review_values['review'],'90') ?> <a href="<?= $review_lurl ?>">more</a></p>

</div>

</div>
</div>
</div>

<!-- End customer reviews -->


<? } ?>



















</div>

<!-- End right column -->






<?

	$template->ld_foot();
	
?>